package org.orion.engine.util;

import java.nio.Buffer;

import javax.media.opengl.GL;

import org.orion.engine.Mesh;
import org.orion.engine.math.VectorUtils;

public class TestMesh {
	
	private static Mesh quadMesh = null;
	private static final Buffer quadData = VectorUtils.toBuffer(new float[]{
			0.0f,0.0f, 0.0f,1.0f,0.0f, -1.0f,0.0f,-1.0f,
			0.0f,1.0f, 0.0f,1.0f,0.0f, -1.0f,0.0f,1.0f,
			1.0f,1.0f, 0.0f,1.0f,0.0f, 1.0f,0.0f,1.0f,
			
			0.0f,0.0f, 0.0f,1.0f,0.0f, -1.0f,0.0f,-1.0f,
			1.0f,0.0f, 0.0f,1.0f,0.0f, 1.0f,0.0f,-1.0f,
			1.0f,1.0f, 0.0f,1.0f,0.0f, 1.0f,0.0f,1.0f,});
	
	private static Mesh cubMesh = null;
	private static final Buffer cubData = VectorUtils.toBuffer(new float[]{
			0.0f,0.0f, 0.0f,-1.0f,0.0f, -1.0f,-1.0f,-1.0f,
			0.0f,1.0f, 0.0f,-1.0f,0.0f, -1.0f,-1.0f,1.0f,
			1.0f,1.0f, 0.0f,-1.0f,0.0f, 1.0f,-1.0f,1.0f,
			0.0f,0.0f, 0.0f,-1.0f,0.0f, -1.0f,-1.0f,-1.0f,
			1.0f,0.0f, 0.0f,-1.0f,0.0f, 1.0f,-1.0f,-1.0f,
			1.0f,1.0f, 0.0f,-1.0f,0.0f, 1.0f,-1.0f,1.0f,
			
			0.0f,0.0f, 0.0f,1.0f,0.0f, -1.0f,1.0f,-1.0f,
			0.0f,1.0f, 0.0f,1.0f,0.0f, -1.0f,1.0f,1.0f,
			1.0f,1.0f, 0.0f,1.0f,0.0f, 1.0f,1.0f,1.0f,
			0.0f,0.0f, 0.0f,1.0f,0.0f, -1.0f,1.0f,-1.0f,
			1.0f,0.0f, 0.0f,1.0f,0.0f, 1.0f,1.0f,-1.0f,
			1.0f,1.0f, 0.0f,1.0f,0.0f, 1.0f,1.0f,1.0f,
			
			0.0f,0.0f, -1.0f,0.0f,0.0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1.0f,1.0f, 0.0f,0.0f,1.0f, 1.0f,1.0f,1.0f,});
	
	private static Mesh axisMesh = null;
	private static final Buffer axisData = VectorUtils.toBuffer(new float[]{
			0.0f,0.0f,0.0f,	1.0f,0.0f,0.0f,
			1.0f,0.0f,0.0f, 1.0f,0.0f,0.2f,
			
			0.0f,0.0f,0.0f,	0.0f,1.0f,0.0f,
			//0.0f,1.0f,0.0f, 0.0f,0.9f,0.0f,
			
			0.0f,0.0f,0.0f,	0.0f,0.0f,1.0f,
			0.0f,0.0f,1.0f, 0.2f,0.0f,1.0f
			});
	
	private static Mesh trianglesMesh = null;	
	private static final Buffer trianglesData = VectorUtils.toBuffer(new float[]{
			0.0f,0.0f,0.0f,	1.0f,0.0f,0.0f,	0.0f,1.0f,0.0f, 
			0.0f,0.0f,0.0f,	0.0f,1.0f,0.0f,	0.0f,0.0f,1.0f, 
			0.0f,0.0f,0.0f,	0.0f,0.0f,1.0f,	1.0f,0.0f,0.0f });	
	
	public static Mesh quad(){
		if (quadMesh==null){
			quadMesh = new Mesh(GL.GL_T2F_N3F_V3F,quadData);
		}
		return quadMesh;
		
	}
	
	public static Mesh cub(){
		if (cubMesh==null){
			cubMesh = new Mesh(GL.GL_T2F_N3F_V3F,cubData);
		}
		return cubMesh;
		
	}
	
	public static Mesh axis(){
		if (axisMesh==null){
			axisMesh = new Mesh(GL.GL_V3F,GL.GL_LINES,axisData);
		}	
		return axisMesh;
		
	}
	
	public static Mesh traiangles(){
		if (trianglesMesh==null){
			trianglesMesh = new Mesh(GL.GL_V3F,trianglesData);
		}	
		return trianglesMesh;
		
	}
	
	
}
